{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Necessary conditions for Max Clique \n",
    "### Install pyQUBO from Recruit Communications Co. Ltd.\n",
    "    pip install pyqubo\n",
    "### Install openJij from Jij Inc.  (startup from Tohoku University)\n",
    "    pip install openjij"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Add networkx for dealing with graph theory"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "        pip install networkx"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Solve Max Clique"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### import pyQUBO, openJij, numpy and matplotlib"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyqubo  import Array,Constraint, Placeholder\n",
    "import openjij as jij\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Array, Constrains and Placeholders are convenient classes from pyQUBO"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### import networkx"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import networkx as nx"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Prepare some graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "nodes = [0, 1, 2, 3, 4, 5]\n",
    "edges = [\n",
    "    (0, 1), (1, 2), (2, 4), (1, 3),\n",
    "    (3, 4), (4, 5), (3, 5)\n",
    "    ]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Set nodes and edges on Graph G"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "G = nx.Graph()\n",
    "G.add_nodes_from(nodes)\n",
    "G.add_edges_from(edges)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAekUlEQVR4nO3deXxddbnv8c+ToU06D7RYyhARQQSKIshM7UGBkipHUZHJWi4gMujRXpXo8R6vqOEoVebhqFcqw1FRQEqYBCkgXD3MZVA8AilQLHSglLZJk2Y/54/fSkmTnTTZSfZv7b2+79crL2UPaz1F+fLLs36DuTsiIlIcFbELEBHJEoWuiEgRKXRFRIpIoSsiUkQKXRGRIlLoiogUUVXsAkRE0qKuoWkqMBeYAUwA1gBLgKubG+tXDMU9TPN0RSTr6hqa9gMagNmAA7Vd3m4BDLgdaGxurH94MPdS6IpIptU1NJ0BLABq6LvlmgNagfnNjfVXFno/ha6IZFaXwB01gK9tYBDBq9AVkUxKWgqLGVjgdtoAzGxurH9koF/UgzQRyaoGQkthCx0tb7HqtotobX6citpxTJw5l9F7fKj7x2qS7x870JtqypiIZE4yS2E2eTJw9V1XYJXVbH/OtWzz0f/Nqrsup23F0u4fqwCOrmtomjLQeyt0RSSL5hJmKWwh19bKhuceYsJhJ1ExopaaHfZg1C77s/6Ze/Ndw5PrDIhCV0SyaAZbTgsDYNPqZVhFJdWTpm9+rXrqO2nvOdIl+f6Mgd5YoSsiWTQh34u59hZs5JZZXDFyFLm2lgFdpy8KXRHJojX5XqyorsU3bhmwvnEDFSN6DIr7vE5fFLoikkVL3L21+4tVk6bjuQ7aVy/b/Frb6y9SPWWnfNdoISwRHhCFrohkipntuuzKU/ego73HdLGKETWM2u1A1jxwHbm2VlpfeZYNf/8zo/eYlfdSwMKB3l+hKyJlz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IZNKY10YYg2N09Gt18g9IlvBQ5V4IpIMZTE7IVOyblpLwMfcvfnCrzGTsDPgLHA59z9L0NYoohIn0oqdAHM7EdVk6b79NOvWg7MACYAa4AlwNXNjfUrevmeAacR9rpdAFzg7puKVLaICFBioVvX0LRfx4Y3z68YUTuLyurWZM/dTi2AAbcDjc2N9Q93vmFmOxBGt5OAue7+TFELFxFJlExPt66h6QxgcUXtuA9Z1QjrFrgAtUANcAywuK6h6QwLTgEeI+xYdqACV0RiKomRbhK4C4BR/f2Ou7eseeC6F9Y+9Mt2wuh2ybAVKCLST6kP3bqGpv2AxXQL3OXXncvGV5/DKioBqBw7memnX7XFd71jU3uureXQly/8zJ+LVK6ISJ9KYZ5uA6Ft0MOkI85g7N5H9vpFq6yqrKwd+zXg2GGqTURkQFLd061raJoKzKbwOiuAo+samqYMXVUiIoVLdegCc4Fe+x9rFi/k5YtOYPk1X6V1aa8tW0+uIyISXdrbCzMIsxJ6mDhrHtWTd8Aqq1n/l/t5/bfnMW3exVRPnNb9o7XJdUREokv7SHdCb2+M3G43KkaOwqqqGbPX4Yycvjstzz8y4OuIiBRT2kN3Tb8/aUZfnYihKEZEZLDSHrpLCCvNtpBrXUfLC4/im9rwXAfrnrmXjS8/Te3OH8h3jZbkOiIi0aW9p7sQ+E73Fz3XwZr7r6V99StgFVRP3p4pn/hXqidNz3cNS64jIhJdKSyOuJGwtLeQUXkOuLm5sV7zdEUkFdLeXgBoBFoL/G5r8n0RkVRIfegmu4XNBwZ6CvAGYH5zY32vUxpERIot9e2FTl02vamh739Z5Agj3PnNjfVXFqM2EZH+KpnQBahraNqXsBfD0YT5Yfn2072NsJ+uRrgikjolFbqdkr0U5tLz5IiFvZ0cISKSBiUZuiIipSr1D9JERMqJQldEpIgUuiIiRaTQFREpIoWuiEgRKXRFRIrofwDjZYoZXeVTagAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "nx.draw_networkx(G)\n",
    "plt.axis(\"off\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Prepare binary variables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "N = 6\n",
    "K = 3\n",
    "vartype = \"BINARY\"\n",
    "q = Array.create(\"q\",shape=N,vartype=vartype)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\"q\" is name of variables  \n",
    "shape specifies the shape of variables as vector, matrix, or...  \n",
    "vartype selects -1 or 1 by \"SPIN\" and 0 or 1by \"BINARY\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Array([Binary(q[0]), Binary(q[1]), Binary(q[2]), Binary(q[3]), Binary(q[4]), Binary(q[5])])\n"
     ]
    }
   ],
   "source": [
    "print(q)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Define cost function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "E1 = Constraint(0.5*(np.sum(q)-K)**2,\"K\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "E2 = 0\n",
    "for e in edges:\n",
    "    E2 += - q[e[0]]*q[e[1]]\n",
    "E2 += 0.5*K*(K-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "Lam = Placeholder('Lam')\n",
    "E_cost = Lam*E1+E2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Compile the cost function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = E_cost.compile()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Get qubo matrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "feed_dict = {'Lam': 5.0}\n",
    "Q, offset = model.to_qubo(feed_dict=feed_dict)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Prepare simulation of quantum annealing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [],
   "source": [
    "#simulated quantum annealing\n",
    "sampler = jij.SQASampler(beta=10.0, gamma=1.0, trotter=4, num_sweeps=100)\n",
    "#simulated annealing\n",
    "#sampler = jij.SASampler(num_sweeps=1000)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is done by quantum Monte-Carlo simulation  \n",
    "gamma = strength of quantum fluctuation  \n",
    "trotter = Trotter number  \n",
    "num_sweeps = length of MCS"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Let's simulate quantum annealing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [],
   "source": [
    "response = sampler.sample_qubo(Q,num_reads=100)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Show results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   q[0] q[1] q[2] q[3] q[4] q[5] energy num_oc.\n",
      "0     0    0    0    1    1    1  -25.5       1\n",
      "1     0    0    0    1    1    1  -25.5       1\n",
      "2     0    0    0    1    1    1  -25.5       1\n",
      "3     0    0    0    1    1    1  -25.5       1\n",
      "4     0    0    0    1    1    1  -25.5       1\n",
      "6     0    0    0    1    1    1  -25.5       1\n",
      "8     0    0    0    1    1    1  -25.5       1\n",
      "9     0    0    0    1    1    1  -25.5       1\n",
      "10    0    0    0    1    1    1  -25.5       1\n",
      "13    0    0    0    1    1    1  -25.5       1\n",
      "15    0    0    0    1    1    1  -25.5       1\n",
      "16    0    0    0    1    1    1  -25.5       1\n",
      "17    0    0    0    1    1    1  -25.5       1\n",
      "21    0    0    0    1    1    1  -25.5       1\n",
      "22    0    0    0    1    1    1  -25.5       1\n",
      "23    0    0    0    1    1    1  -25.5       1\n",
      "24    0    0    0    1    1    1  -25.5       1\n",
      "25    0    0    0    1    1    1  -25.5       1\n",
      "28    0    0    0    1    1    1  -25.5       1\n",
      "29    0    0    0    1    1    1  -25.5       1\n",
      "31    0    0    0    1    1    1  -25.5       1\n",
      "32    0    0    0    1    1    1  -25.5       1\n",
      "33    0    0    0    1    1    1  -25.5       1\n",
      "35    0    0    0    1    1    1  -25.5       1\n",
      "36    0    0    0    1    1    1  -25.5       1\n",
      "37    0    0    0    1    1    1  -25.5       1\n",
      "38    0    0    0    1    1    1  -25.5       1\n",
      "40    0    0    0    1    1    1  -25.5       1\n",
      "41    0    0    0    1    1    1  -25.5       1\n",
      "42    0    0    0    1    1    1  -25.5       1\n",
      "43    0    0    0    1    1    1  -25.5       1\n",
      "45    0    0    0    1    1    1  -25.5       1\n",
      "46    0    0    0    1    1    1  -25.5       1\n",
      "47    0    0    0    1    1    1  -25.5       1\n",
      "48    0    0    0    1    1    1  -25.5       1\n",
      "49    0    0    0    1    1    1  -25.5       1\n",
      "50    0    0    0    1    1    1  -25.5       1\n",
      "52    0    0    0    1    1    1  -25.5       1\n",
      "53    0    0    0    1    1    1  -25.5       1\n",
      "54    0    0    0    1    1    1  -25.5       1\n",
      "55    0    0    0    1    1    1  -25.5       1\n",
      "56    0    0    0    1    1    1  -25.5       1\n",
      "57    0    0    0    1    1    1  -25.5       1\n",
      "58    0    0    0    1    1    1  -25.5       1\n",
      "59    0    0    0    1    1    1  -25.5       1\n",
      "60    0    0    0    1    1    1  -25.5       1\n",
      "61    0    0    0    1    1    1  -25.5       1\n",
      "62    0    0    0    1    1    1  -25.5       1\n",
      "63    0    0    0    1    1    1  -25.5       1\n",
      "64    0    0    0    1    1    1  -25.5       1\n",
      "66    0    0    0    1    1    1  -25.5       1\n",
      "67    0    0    0    1    1    1  -25.5       1\n",
      "68    0    0    0    1    1    1  -25.5       1\n",
      "69    0    0    0    1    1    1  -25.5       1\n",
      "70    0    0    0    1    1    1  -25.5       1\n",
      "73    0    0    0    1    1    1  -25.5       1\n",
      "74    0    0    0    1    1    1  -25.5       1\n",
      "75    0    0    0    1    1    1  -25.5       1\n",
      "76    0    0    0    1    1    1  -25.5       1\n",
      "77    0    0    0    1    1    1  -25.5       1\n",
      "78    0    0    0    1    1    1  -25.5       1\n",
      "79    0    0    0    1    1    1  -25.5       1\n",
      "80    0    0    0    1    1    1  -25.5       1\n",
      "81    0    0    0    1    1    1  -25.5       1\n",
      "83    0    0    0    1    1    1  -25.5       1\n",
      "85    0    0    0    1    1    1  -25.5       1\n",
      "86    0    0    0    1    1    1  -25.5       1\n",
      "87    0    0    0    1    1    1  -25.5       1\n",
      "89    0    0    0    1    1    1  -25.5       1\n",
      "90    0    0    0    1    1    1  -25.5       1\n",
      "91    0    0    0    1    1    1  -25.5       1\n",
      "92    0    0    0    1    1    1  -25.5       1\n",
      "93    0    0    0    1    1    1  -25.5       1\n",
      "94    0    0    0    1    1    1  -25.5       1\n",
      "96    0    0    0    1    1    1  -25.5       1\n",
      "97    0    0    0    1    1    1  -25.5       1\n",
      "98    0    0    0    1    1    1  -25.5       1\n",
      "99    0    0    0    1    1    1  -25.5       1\n",
      "5     1    1    1    0    0    0  -24.5       1\n",
      "7     0    1    1    0    1    0  -24.5       1\n",
      "11    1    1    1    0    0    0  -24.5       1\n",
      "12    0    1    1    1    0    0  -24.5       1\n",
      "14    0    1    1    0    1    0  -24.5       1\n",
      "18    0    1    0    1    1    0  -24.5       1\n",
      "19    0    0    1    0    1    1  -24.5       1\n",
      "20    0    1    1    0    1    0  -24.5       1\n",
      "26    0    1    0    1    1    0  -24.5       1\n",
      "27    0    1    0    1    1    0  -24.5       1\n",
      "30    0    1    0    1    1    0  -24.5       1\n",
      "34    0    1    0    1    1    0  -24.5       1\n",
      "39    0    0    1    1    1    0  -24.5       1\n",
      "44    1    1    1    0    0    0  -24.5       1\n",
      "51    0    1    0    1    1    0  -24.5       1\n",
      "65    0    0    1    1    1    0  -24.5       1\n",
      "71    0    1    1    1    0    0  -24.5       1\n",
      "72    0    1    0    1    1    0  -24.5       1\n",
      "82    0    1    1    0    1    0  -24.5       1\n",
      "84    0    1    0    1    1    0  -24.5       1\n",
      "88    0    0    1    1    1    0  -24.5       1\n",
      "95    0    1    1    1    0    0  -24.5       1\n",
      "['BINARY', 100 rows, 100 samples, 6 variables]\n"
     ]
    }
   ],
   "source": [
    "print(response)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### minimum sample"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [1, 1, 1, 0, 0, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 1, 1, 0, 1, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [1, 1, 1, 0, 0, 0],\n",
       "       [0, 1, 1, 1, 0, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 1, 1, 0, 1, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 1, 0, 1, 1, 0],\n",
       "       [0, 0, 1, 0, 1, 1],\n",
       "       [0, 1, 1, 0, 1, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 1, 0, 1, 1, 0],\n",
       "       [0, 1, 0, 1, 1, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 1, 0, 1, 1, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 1, 0, 1, 1, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 1, 1, 1, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [1, 1, 1, 0, 0, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 1, 0, 1, 1, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 1, 1, 1, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 1, 1, 1, 0, 0],\n",
       "       [0, 1, 0, 1, 1, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 1, 1, 0, 1, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 1, 0, 1, 1, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 1, 1, 1, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 1, 1, 1, 0, 0],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1],\n",
       "       [0, 0, 0, 1, 1, 1]], dtype=int8)"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "response.record[\"sample\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### show resulting graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO3deXycZbn/8c/1JF3TlgJtSdmXEgpFVqEgrkBEFnENyw9FRVAOiHJcgKMedxEPIosHkUX5ocIB4zmAHEV+URAXpAgFZCmElq0sobSldEnXPNfvj/tpmZnMJJNJZp5Zvu/Xa14pM5PMnZJ8e8/93Nd1m7sjIiKVEaU9ABGRRqLQFRGpIIWuiEgFKXRFRCpIoSsiUkEKXRGRCmpOewC1Lu5p2xs4GzgMmAhsABYD1wDXRq3dS1McnohUGdM+3dLEPW3vBC4FZgCj6f8PWC/hncQtwGej1u5XKzpAEalKCt0SxD1tHwOuAMYV8fT1hJnv26LW7gVlHZiIVD2F7hDFPW3vB26guMDd9GnAImDvqLV7UVkGJiI1QRfShiDuadsMuJ6hBS6Ev+ctgatGfFAiUlMUukNzMpD3rcGhH3yB8TvOZ9Iu4bb7W5/Nfcoo4Ii4p621zGMUkSqm0C1S3NNmwJeAlkLPuey7U1m+YAbLF8xg3l93LPS0T5VheCJSIxS6xdsH2HyYX2MscNoIjEVEapRCt3jTgb6BnvCV85cwbY8FvO3Yhfzpnt5CT9tyxEcmIjVDxRHFGwNYoQe/99Up7NE2mtGj4MZbV/K+k19i7h+2Z5cdR2c9z91HlXugIlK9NNMt3jIKXEQDmL3fWCZOiBgzJuJjx03iLQeM4/Y/9p/tLl8RN5vZAjP7vZn9yMw+a2ZHmtkMM9M/giJ1Tr/kxXuYMNstihnk2QLtE1qiO4EzgF2T227AMcmfp5vZ88BTeW7Pu/uAyxs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gY8TwnagoouJwCTg1+1Rx0fKOnApSKErUgMyiisOImw1e8LMTnD3y4F3AS1D+HLjgKvao453lWGoMggtL4jUIDN7ewuTLp/NYXtE1tRv8rTe1/E497OEVxjNGGawJ622fe7TuoGZXXGnQqCCNNMVqUHu/ueDaP+TEeUNzCd4kIiIt/Ne9uRA5jGXlf567tO2IcyapYIUuiI1qD3qGG9mnzCzptzH+nwDi3iBnZlFszUz2aYwla15medznzoO+EJFBiybKHRFatP+wIZ8D6xiBUZEi03cdN9ENmMVy3OfGgHvLtsIJS+Frkht2rzQA31soJnsYrZmRrGB9fmePmGExyWDUOiK1Ka40ANNNLMhZxK8gQ00M2pIX0fKQ6ErUptepcDvbwsTcWJ6fcWm+1awjBbyHlLcb81BykuhK1KbHiD04u2nyZqZxjYs4ObJ3sYAAAEFSURBVHH6fAPLfDGv8hLT6bdlbD1wU7kHKtkUuiI1qCvu3ABcBuTtozCT/Yjp425u4xHmsDv7MaF/x8i+5GtIBak4QqRGtUcdWwHPMnDpbyEOzOmKOw8e0UHJoDTTFalRXXHnK8C/EXoyDNVK4JSRHZEUQ6ErUsO64s5LCEsExQavE7qNHdUVd84r28CkIC0viNSB9qjjVOBCQh/diXme0gesJfTmPaEr7nysgsOTDApdkTqRnBjxfuA8YB9C0EaEXQq/Bi7uijvnpjdCAYWuSF1qjzqMMONdp5MiqotCV0SkgnQhTUSkghS6IiIVpNAVEakgha6ISAUpdEVEKkihKyJSQf8f0e68zruhg8AAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "spin = response.record[\"sample\"][0]\n",
    "node_colors = [spin[node]>0 for node in G.nodes()]\n",
    "\n",
    "nx.draw_networkx(G,node_color=node_colors)\n",
    "plt.axis(\"off\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
